/**
 * 
 */
package messenger;

import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.GregorianCalendar;

/**
 * @author (Group 42) William Orem, Joseph Hamilton, Kevin Benik
 * 
 */
public class MessageLog implements Serializable {
	/**
	 * 
	 */
	private static final long serialVersionUID = 7126703906733538961L;
	private GregorianCalendar startDate;
	private GregorianCalendar stopDate;
	private ArrayList<Message> messages;

	/**
	 * 
	 */
	public MessageLog() {
		this.messages = new ArrayList<Message>();
	}

	/**
	 * @return the messages
	 */
	public ArrayList<Message> getMessages() {
		return messages;
	}

	/**
	 * @return the startDate
	 */
	public GregorianCalendar getStartDate() {
		return startDate;
	}

	/**
	 * @return the stopDate
	 */
	public GregorianCalendar getStopDate() {
		return stopDate;
	}

	/**
	 * @param inputStream
	 * @throws IOException
	 */
	@SuppressWarnings("unchecked")
	public void readObject(ObjectInputStream inputStream) throws IOException {
		try {
			this.startDate = (GregorianCalendar) inputStream.readObject();
			this.stopDate = (GregorianCalendar) inputStream.readObject();
			this.messages = (ArrayList<Message>) inputStream.readObject();
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		}
	}

	/**
	 * @param messages
	 *            the messages to set
	 */
	public void setMessages(ArrayList<Message> messages) {
		this.messages = messages;
	}

	/**
	 * @param stopDate
	 *            the stopDate to set
	 */

	/**
	 * @param startDate
	 *            the startDate to set
	 */
	public void setStartDate(GregorianCalendar startDate) {
		this.startDate = startDate;
	}

	/**
	 * @param stopDate
	 */
	public void setStopDate(GregorianCalendar stopDate) {
		this.stopDate = stopDate;
	}

	/**
	 * 
	 * @param outputStream
	 * @throws IOException
	 */
	public void writeObject(ObjectOutputStream outputStream) throws IOException {
		// outputStream.defaultWriteObject();
		outputStream.writeObject(startDate);
		outputStream.writeObject(stopDate);
		outputStream.writeObject(messages);
	}

}
